www.gusucode.com > 地方成人教育中心整站源代码 1 > 地方成人教育中心整站源代码 1.0/js/roll.js
// JavaScript Document // jQuery滚动插件 function scro(obj,type){ $(obj).diaScroll({direction:type}); } (function($){ $.fn.diaScroll = function(opt){ return this.each(function(){ var cfg = $.extend({ speed : 100, direction : 'top', listContainer : 'ul', cloneChild : 'li', cloneContainer : 'ul', firstCloneClass : 'clone-first-child' },opt), $ctnr = $(cfg.listContainer,this), $clone = $(cfg.cloneChild,$ctnr).clone().appendTo($(cfg.cloneContainer,this)).eq(0).addClass(cfg.firstCloneClass), timer; var offset = $ctnr.offset(); var aniStyle; switch(cfg.direction){ case 'top' : aniStyle = { top : '-=1'}; break; case 'left' : aniStyle = { left : '-=1'}; break; } var play = function(){ timer = setInterval(function(){ if($clone.offset()[cfg.direction] <= offset[cfg.direction]) $ctnr.offset(offset); else $ctnr.animate(aniStyle,0); },cfg.speed); }; var stop = function(){ clearInterval(timer); }; play(); $ctnr.hover(stop,play); }); }; })(jQuery); function rolls(){ $('.noticelistcont').diaScroll({speed:100}); $('#demo-ul-h').diaScroll({speed:50,direction:'left'}); }